package org.vectrics.struts.tags;

import java.io.IOException;
import java.text.SimpleDateFormat;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

import org.apache.log4j.Category;

public class TextGraphicTag extends TagSupport {
    static private Category log = Category.getInstance(TextGraphicTag.class);

    private String server = null;

    private static SimpleDateFormat historyDateFormat = new SimpleDateFormat("dd/MM/yyyy");

    public TextGraphicTag() {
    }

    @Override
    public int doStartTag() throws JspException {
        log.debug("doStartTag() called");
        HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

        String html = "<img src=\"http://" + server + "/graphics-gen/mike.jpg?type=text&text=Mike%20Moore&size="
                + "100&width=900&height=400" + "\">";

        log.debug("doStartTag() - writing output...");
        JspWriter writer = pageContext.getOut();
        try {
            writer.print(html);
        } catch (IOException ex) {
            throw new JspException("IOException attempting to write tag to output. " + ex.getMessage());
        }
        return EVAL_PAGE;
    }
}
